using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ManualTargetSystem : Singleton<ManualTargetSystem>
{
    [SerializeField] private ArrowView arrowView;
   
    [SerializeField] private LayerMask targetLayer; 

    public void StartTargeting(Vector3 startPosition)
    {
        arrowView.gameObject.SetActive(true);
        arrowView.SetupArrow(startPosition);
    }
    public EnemyView EndTargeting(Vector3 endPosition)
    {
        arrowView.gameObject.SetActive(false);
        if ((Physics.Raycast(endPosition, Vector3.forward, out RaycastHit hit,10, targetLayer)
            &&hit.collider!=null&&hit.transform.TryGetComponent(out EnemyView enemyView)))
        {
            return enemyView;
        }
        return null;
    }
    public void Update()
    {
        //if (Input.GetMouseButtonDown(0))
        //{
        //     var enemy=   EndTargeting(MouseUtil.GetMousePositionInWorldSpace(-1));
        //    if (enemy != null)
        //    {
        //        Debug.Log("Enemy selected"+enemy.name);
        //    }
        //    else
        //    {
        //        Debug.Log("未检测到敌人   ");
        //    }
        //}

    }
}
